<?php 
$conId = 'goods-detail';
$now_product_id = Yii::$app->request->get ( 'product_id');
use common\helper\StringHelper;

?>

<?php $this->beginBlock('css');?>
  <link rel="stylesheet" type="text/css" href="<?=Yii::getAlias('@static')?>/wap/liketry/css/goods.css">
<?php $this->endBlock();?>
	<header>
      <div class="header-left" onclick="history.go(-1)"><span class="icon icon-arrow-left"></span></div>
      <h1>商品详情</h1>
      <div class="header-right" onclick="$.go('<?=Yii::$app->urlManager->createUrl(['index'])?>');" ><span class="icon icon-home"></span></div>
    </header>
    <section class="goods-detail">
    	<div class="goods-slider">
    		<div class="swiper-wrapper box-flex">
				<!--商品图片循环 Start-->
				<?php 
				if(is_array($goods_info['gallery_list'])):
				$img_flag = 0;
				if (!empty($goods_info['image']['compress_thumb'])) {
				    $img_flag = 1;
				}
				foreach ($goods_info['gallery_list'] as $imkey=>$imval):?>
	              <div class="swiper-slide flexSh"><img src="
	              	<?php 
	              	$url_img = str_replace('./upload/', 'upload/', $imval['thumb']);
	              	if ($now_product_id < 20000000 || $now_product_id > 40000000) {
                        if ($img_flag == 1) {
                            $url_img = str_replace('/compress', '', $url_img);
                        } else {
                            $url_img = str_replace('/thumb', '', $url_img);
                        }
	                }
	              	echo \Yii::$app->params['goods_image_url'] . $url_img;
	              	?>
	              	">
	              </div>
				<?php 
				endforeach;
				endif;?>
				<!--商品图片循环 End-->
			</div>
			<div class="img-num"><span>1</span>/<span>1</span></div>
    	</div>
    	
		<div class="goods-main">
			<div class="goods-top ">
				<h2 class="twoline"><?php echo StringHelper::subtext($goods_info['goods_name'], 40);?></h2>
				<h3><?php echo StringHelper::subtext($goods_info['goods_desc'],40)?></h3>
				<?php if($goods_info['type'] != 1):?>
				<p class="price1">价&nbsp;&nbsp;&nbsp;格：<span><?php echo $goods_info['sale_price'];?></span></p>
				<?php endif;?>
				<?php if($goods_info['type'] != 2):?>
				<p class="price1">试用价：<span><?php echo $goods_info['try_price'];?></span></p>
				<?php endif;?>
				<?php if($goods_info['auto_date']>0):?>
				<p class="countdown" data="<?php echo !empty($goods_info['auto_date'])?$goods_info['auto_date']:0?>"><i class="icon-countdown"></i>开放倒计时：<span>23小时59分59秒</span></p>
				<?php endif;?>
			</div>
			<?php if (!empty($fullcut)):?>
			<div class="goods-mes full-cut close">
				<div class="key">优惠</div>
				<div class="value">
					<span>满减</span>
					<p><?php echo $fullcut;?></p>
				</div>
				<div class="arrow"></div>
			</div>
			<?php endif;?>
			<div class="goods-mes choose close">
				<div class="line line1">
					<div class="key">已选</div>
					<div class="value">
						<?php if(!empty($goods_info['defsku1'])):?>
							<p><?php echo $goods_info['defsku1'];?></p>
						<?php endif;?>
						<?php if(!empty($goods_info['defsku2'])):?>
							<p><?php echo $goods_info['defsku2'];?></p>
						<?php endif;?>
						<p id="chooseNum">1件</p>
					</div>
				</div>
				<div class="line line2 guige">
					<?php echo $sku1;?>
				</div>
				<div class="line line3 guige">
					<?php echo $sku2;?>
				</div>
				<div class="line line4">
					<div class="key">数量</div>
					<div class="value">
						<span class="amount-reduce dis">-</span>
		                <input class="amount-input" type="text" value="1" id="amountNum">
		                <span class="amount-add">+</span>
					</div>
				</div>
				<i class="arrow icon-arrow-down"></i>
			</div>
			<div class="goods-mes comment">
				<a href="<?=Yii::$app->urlManager->createUrl(["goods-detail/comment",'product_id'=>Yii::$app->request->get ( 'product_id' )]);?>">
					<div class="key">商品评价 </div>
					<div class="value">
						<p><span><?php echo !empty($backRate['a'])?$backRate['a']:0;?>%</span>好评 </p>
						<p><?php echo !empty($backNum)?$backNum:0;?>人评价</p>
					</div>
					<i class="arrow icon-arrow-right"></i>
				</a>
			</div>
			<div class="goods-mes detail">
				<a href="<?=Yii::$app->urlManager->createUrl(["goods-detail/content",'goods_id'=>$goods_info['goods_id']]);?>"><div class="key">商品详情 </div><i class="arrow icon-arrow-right"></i></a>
			</div>
		</div>
		<div class="buy-btn">
		<div class="box">
			<?php if($goods_info['type'] != 1):?>
			<a id="salebtn" class="box-sizing flex1 go 
			<?php if($now_product_id < 20000000 || $now_product_id > 40000000):?>
			<?php if(empty($goods_info['auto_date']) || $goods_info['auto_date'] < 0):?>
			<?php if(!empty($goods_info['stype1']) && $goods_info['stype1'] ==1):?>
			<?php if(empty($goods_info['goods_auto_dw']) || $goods_info['goods_auto_dw'] > time()): ?>
			    cur
			<?php endif;?>
			<?php endif;?>
			<?php endif;?>
			<?php endif;?>">
			<?php if(!empty($goods_info['stype1']) && $goods_info['stype1'] ==1):?>
			<?php if(empty($goods_info['goods_auto_dw']) || $goods_info['goods_auto_dw'] > time()):?>
			    购 买
			<?php endif;?>
			<?php endif;?>
			<?php if(empty($goods_info['stype1']) || (!empty($goods_info['goods_auto_dw']) && $goods_info['goods_auto_dw'] < time())):?>
			    已售完
			<?php endif;?>
			</a>
			<?php endif;?>
			<?php if($goods_info['type'] != 2):?>
			<a id="trybtn" title="同件商品限申领一次" class="box-sizing  flex1 try 
			<?php if($now_product_id < 20000000 || $now_product_id > 40000000):?>
			<?php if(empty($goods_info['auto_date']) || $goods_info['auto_date'] < 0):?>
			<?php if(!empty($goods_info['stype']) && $goods_info['stype'] ==1):?>
			<?php if(empty($goods_info['goods_auto_dw']) || $goods_info['goods_auto_dw'] > time()): ?>
			    cur
			<?php endif;?>	
			<?php endif;?>
			<?php endif;?>
			<?php endif;?>">
			<?php if(!empty($goods_info['stype']) && $goods_info['stype'] ==1):?>
			<?php if(empty($goods_info['goods_auto_dw']) || $goods_info['goods_auto_dw'] > time()):?>
			    试 用
			<?php endif;?>
			<?php endif;?>
			<?php if(empty($goods_info['stype']) || (!empty($goods_info['goods_auto_dw']) && $goods_info['goods_auto_dw'] < time())):?>
			    已领完
			<?php endif;?>
			</a>
			<?php endif;?>
		</div>
		</div>
    </section>

	
	<div class="fixed-right">
		<?php
	    if($bestry_uid){
	        ?>
	        <?php if($goods_info['cartnum']>0&&$goods_info['cartnum']<100){?>
	            <div class="cart" id="cart"><a href="<?=Yii::$app->urlManager->createUrl(["cart"]);?>">
	                <p style="display:block"><?php echo $goods_info['cartnum']?></p>
	            </a></div>
	        <?php }else if($goods_info['cartnum']>99){?>
	            <div class="cart" id="cart"><a href="<?=Yii::$app->urlManager->createUrl(["cart"]);?>">
	                <p style="display:block">99+</p>
	            </a></div>
	        <?php }elseif ($goods_info['cartnum']<1) {?>
	            <div class="cart" id="cart"><a href="<?=Yii::$app->urlManager->createUrl(["cart"]);?>">
	                <p style="display:none">0</p>
	            </a></div>
	        <?php }?>
	    <?php }else{?>
	        <div class="cart" id="cart"><a href="<?php echo $login_url?>" >
	            <p style="display:none"></p>
	        </a></div>
	   <?php }?>

        
        <div class="back-top" id="backTop"></div>
    </div>  

<script src="<?=Yii::getAlias('@static')?>/wap/common/js/zepto.min.js"></script>
<script src="<?=Yii::getAlias('@static')?>/wap/common/js/fastclick.min.js"></script>
<script src="<?=Yii::getAlias('@static')?>/wap/common/js/king.wap.js"></script>
<script src="<?=Yii::getAlias('@static')?>/wap/common/js/swiper-3.3.1.jquery.min.js"></script>
<script src="<?=Yii::getAlias('@static')?>/wap/liketry/js/goods-detail.js"></script>
<script>
var goodUrl = "<?=Yii::$app->urlManager->createUrl(["$conId/index",'product_id'=>'']);?>";
var goodsId = <?php echo $goods_info['goods_id']?>;	//商品id
var addCarUrl = "<?=Yii::$app->urlManager->createUrl(["cart/add-cart"]);?>";	//加入购物车
var goPayUrl = "<?=Yii::$app->urlManager->createUrl(["cart"]);?>";		//去购物车
var tryid = <?php echo !empty($goods_info['try_pid'])?$goods_info['try_pid']:0?>;	//加入购物车--试用id
var saleid = <?php echo !empty($goods_info['sale_pid'])?$goods_info['sale_pid']:0?>;	//加入购物车--购买id
var skuUrl = "<?=Yii::$app->urlManager->createUrl(["$conId/jumping",'goods_id'=>$goods_info['goods_id']]);?>";	//规格+
var login_url = "<?php echo $login_url?>" //WAP端登入地址
//图片规则标记变量
var img_flag = "<?= $img_flag ?>";
</script>